﻿using System.Diagnostics;

namespace System.Lua.Tests
{
    [DebuggerDisplay("Name = {Name}")]
    public class User : IEquatable<User>
    {
        public string Name { get; set; }
        public User[] Friends { get; set; }

        public bool Equals(User other)
        {
            if (ReferenceEquals(null, other))
                return false;
            if (ReferenceEquals(this, other))
                return true;
            return Equals(other.Name, Name);
        }

        public override bool Equals(object obj)
        {
            if (ReferenceEquals(null, obj))
                return false;
            if (ReferenceEquals(this, obj))
                return true;
            if (obj.GetType() != typeof(User))
                return false;
            return Equals((User)obj);
        }

        public override int GetHashCode()
        {
            unchecked
            {
                return ((Name != null ? Name.GetHashCode() : 0) * 397);
            }
        }
    }
}
